class Solution:
    def jump(self, nums: list[int]) -> int:
        if len(nums) == 1: return 0

        steps = 0
        curDistance = 0;    # 当前覆盖最远距离下标
        nextDistance = 0  # 下一步最远覆盖
        for i in range(len(nums)):
            nextDistance = max(nextDistance,nums[i] + i)
            if i==curDistance:
                # 遍历到了尽头必须再走一步
                steps += 1
                curDistance = nextDistance
            if curDistance >= len(nums)-1:
                return max(1,steps)
    
s = Solution()
result = s.jump([2,3,1,1,4])
print(result)